package com.botarena.client;

import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.Panel;
import com.google.gwt.user.client.ui.VerticalPanel;

/**
 * Klasa GUI dla strony About
 * 
 * @author wirenth
 *
 */
public class AboutViewer {

	public static Panel createAboutPage() {
		VerticalPanel panel = new VerticalPanel();
		panel.addStyleName("contentMain");
		
		Label title = new Label("About Bot Arena");
		title.setStyleName("title");
		panel.add(title);
		
		Label title1 = new Label("What is it?");
		title1.setStyleName("title2");
		panel.add(title1);
		HTML text1 = new HTML("Bot Arena is a place to test your programming skills. However, this is accomplished NOT by a stupid exam or quiz, BUT by series of life-and-death duels! Well, between bots (AI programs) created by you and other contestants. That's right - you provide the source code, which gets automatically compiled and then periodically executed against adequate opponents. The easy-to-learn and extremely-easy-to-use language that we support is <a href=\"http://en.wikipedia.org/wiki/Python_(programming_language)\">Python</a>.");
		text1.setStyleName("aboutParagraphs");
		panel.add(text1);
		
		Label title2 = new Label("What game are we playing?");
		panel.add(title2);
		title2.setStyleName("title2");
		HTML text2 = new HTML("Current \"Main\" contest features a classic game of <a href=\"http://en.wikipedia.org/wiki/Gomoku\">15x15 Free-style Gomoku</a> (5 symbols to win, overlines are allowed).");
		text2.setStyleName("aboutParagraphs");
		panel.add(text2);
		
		Label title3 = new Label("How to implement my bot?");
		panel.add(title3);
		title3.setStyleName("title2");
		HTML text3 = new HTML("To successfully start its way through defeating all other opponents, your bot needs to conform to a simple interface. Namely, it needs to define a class containing two methods: <b>set_params(str)</b> and <b>int respond(int)</b> and then register an object of this class using a mysterious <b>botarena.register(bot)</b> call. Thus, the easiest bot might look like this:");
		text3.setStyleName("aboutParagraphs");
		panel.add(text3);
		HTML text4 = new HTML(
			"<b>class MyBot:</b><br>" +
			"&nbsp;&nbsp;&nbsp;<b>def set_params(self, params):</b><br>" + 
			"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;# <i>params is a string that you can specify upon uploading or editing of your bot.</i><br>" +
			"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b>self.delta = int(params)</b><br><br>" + 
			"&nbsp;&nbsp;&nbsp;<b>def respond(self, move):</b><br>" +
			"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;# <i>move is an integer denoting position of your opponent's last move.</i><br>" +
			"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;# <i>It is in range of 0-224, as fields of 15x15 game board are numbered row by row, going downwards.</i><br>" +
			"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;# <i>If move equals -1, this means that you are supposed to make a first move.</i><br>" +
			"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;# <i>Your code is supposed to <b>return</b> your move in the same encoding within 1 second time limit.</i><br>" +
			"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;# <i>The implementation below simply replies with a silly move next to opponent's last move.</i><br>" +
			"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b>return move + self.delta</b><br><br>" +
			"<i># The line below is obligatory.</i><br>" + 
			"<b>botarena.register(MyBot())</b>"
		);
		text4.setStyleName("aboutSampleCode");
		panel.add(text4);
		HTML text5 = new HTML("Please feel free to use the code above as a template. But remember not to exceed the <b>1 second time limit</b> and <b>not to import</b> any Python modules (sorry - sandboxing requirement).");
		text5.setStyleName("aboutParagraphs");
		panel.add(text5);
		
		return panel;
	}

}
